package org.example.shop.api;

import org.example.shop.pojo.UserOrder;
import org.example.shop.service.OrderService;
import org.example.shop.util.UserUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin
public class OrderController {
    @Resource
    private OrderService orderService;

    @RequestMapping("/order/buy")
    public UserOrder buy(Long id, int count) {
        UserUtil.checkLogin();
        // 直接写代码 判断是否登录
        return orderService.buy(id, count, 1);
    }
}
